


function asem(fireFunc,initLock){
        if(initLock)
                this.lock=initLock;
        else
                this.lock=0;
        this.func = fireFunc;
}
 
asem.prototype.v = function(){
        this.lock++;
}
 
asem.prototype.p = function(){
        this.lock--;
        if(this.lock==0 && this.func)
                this.func();
}

function getAsem(cbFunc) {
    
    return new asem(cbFunc);
}

exports.getAsem = getAsem;